import 'package:dartx/dartx.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sgy_flutter/ble/base_service.dart';
import 'package:sgy_flutter/gen/assets.gen.dart';
import 'package:sgy_flutter/page/adjust_zero/adjust_zero_record/view.dart';
import 'package:sgy_flutter/widget/app_bar_x.dart';
import 'package:sgy_flutter/widget/sgy_scaffold.dart';

import 'logic.dart';

class AdjustZeroSuccessPage extends StatefulWidget {
  const AdjustZeroSuccessPage({Key? key}) : super(key: key);

  @override
  State<AdjustZeroSuccessPage> createState() => _AdjustZeroSuccessPageState();
}

class _AdjustZeroSuccessPageState extends State<AdjustZeroSuccessPage> {
  final logic = Get.put(AdjustZeroSuccessLogic());

  @override
  Widget build(BuildContext context) {
    return SgyScaffold(
      title: "零点校准".tr,
      child: Obx(
            () => Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Assets.image.iconSuccess
                .image(width: 108, height: 108)
                .marginOnly(top: 80),
            Text(
              "零点校准成功".tr,
              style: TextStyle(fontSize: 20, color: Color(0xff1e1e1e)),
            ).marginOnly(top: 20),
            Text(
              "本次校准结果".tr + ":${logic.currentRecord.value}",
              style: TextStyle(fontSize: 15, color: Color(0xff515151)),
            ).marginOnly(top: 30),
            Text(
              "上次校准结果".tr + ":${logic.lastRecord.value}",
              style: TextStyle(fontSize: 15, color: Color(0xff515151)),
            ).marginOnly(top: 8),
            Spacer(),
            Container(
              margin: EdgeInsets.symmetric(vertical: 16, horizontal: 16),
              child: TextButton(
                  onPressed: () {
                    Get.to(() => AdjustZeroRecordPage());
                  },
                  child: Text("查看历史校准记录 >".tr)),
            ),
          ],
        ),
      ),
    );
  }



  @override
  void dispose() {
    Get.delete<AdjustZeroSuccessLogic>();
    super.dispose();
  }
}
